package com.salestax.core.specific.tax;

import java.math.BigDecimal;
import java.math.RoundingMode;

import com.salestax.core.Product;
import com.salestax.core.Tax;

public class ImportDuty extends Tax {
	

	private BigDecimal rate;

	public ImportDuty(double rate) {
		this.rate = new BigDecimal(rate);
	}

	@Override
	public BigDecimal calculateTax(Product product) {
		assert product != null;
		BigDecimal percentage = rate.divide(new BigDecimal(100));
		BigDecimal result =  product.getBasePrice().multiply(percentage);
		return new BigDecimal(Math.ceil(result.doubleValue() * 20) / 20).setScale(2, RoundingMode.HALF_UP);
		
		
	}
	
	
}
